<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAppsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
		//菜单
        Schema::create('menus', function (Blueprint $table) {
            $table->increments('id')->comment('id值');
            $table->integer('parent_id')->comment('上级id');	
			$table->string('name',100)->comment('菜单名称');
            $table->string('desc',100)->nullable()->comment('');
            $table->string('prefix')->nullable()->comment('路径前缀');
			$table->string('path')->nullable()->comment('菜单路径');
			$table->string('icon')->nullable()->comment('菜单图标');
			$table->string('target')->comment('打开方式:_self窗口内,_blank新窗口');
			$table->integer('order')->default(1)->nullable()->comment('优先级 越小越靠前');
			$table->tinyInteger('status')->default(1)->nullable()->comment('状态:0-无效 1-有效');
			$table->tinyInteger('is_system')->default(1)->nullable()->comment('是否为系统内置');
            $table->timestamps();			
        });
		
		//菜单资源
        Schema::create('access_menu', function (Blueprint $table) {
			$table->integer('menu_id')->comment('菜单id');
			$table->integer('access_id')->comment('权限id');
			$table->primary(['menu_id', 'access_id']);			
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
		Schema::dropIfExists('menus');
		Schema::dropIfExists('access_menu');
    }
}
